/*
 *      Time.h
 *      
 *      Copyright 2009 Daniele Ricci <denn86@gmail.com>, Luca Saccagi <luksak86@gmail.com>
 *      
 *      This program is free software; you can redistribute it and/or modify
 *      it under the terms of the GNU General Public License as published by
 *      the Free Software Foundation; either version 2 of the License, or
 *      (at your option) any later version.
 *      
 *      This program is distributed in the hope that it will be useful,
 *      but WITHOUT ANY WARRANTY; without even the implied warranty of
 *      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *      GNU General Public License for more details.
 *      
 *      You should have received a copy of the GNU General Public License
 *      along with this program; if not, write to the Free Software
 *      Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 *      MA 02110-1301, USA.
 */

#ifndef _TIME
#define _TIME

#include "../idmp.h"


#ifdef _WIN32 //Static attribute needed in function declaration under VS2005
int timestamp(int h,int m, int s);
int dayOfTheYear(int day, int month);
yList *modeTime(int d,char mode);
void setTime(AlertList *root, xmlNode *father);
dailyAlertList *lastTimestamp(iDay *today, int year, long int ts);
dailyAlertList *scanYear(yList *curyear, long int ts);
int parse_time(processingTree *this,char *where,int index,int *i);
void del_time_index(AlertList *to_delete);
void indexTime(AlertList *root,xmlNode *father, char mode);
xmlNodeList *time_filters(processingTree *this,stringList *sel,VortexConnection *cn,VortexChannel *ch);
xmlNodeList *TimeFilter(unsigned char sign_mode,int sign_num,int step_num,const char *timestamp, char mode,stringList *sel,VortexConnection *cn,VortexChannel *ch);
xmlNodeList *notTimeFilter(unsigned char sign_mode,int sign_num,int step_num,const char *tstamp, char mode,stringList *sel,VortexConnection *cn,VortexChannel *ch);
xmlNodeList *betweenTime(unsigned char sign_mode,int sign_num,int step_num,char *time, char mode,stringList *sel,VortexConnection *cn,VortexChannel *ch);
xmlNodeList *notbetweenTime(unsigned char sign_mode,int sign_num,int step_num,char *time, char mode,stringList *sel,VortexConnection *cn,VortexChannel *ch);

#else //Other OS declarations 
inline int timestamp(int h,int m, int s);
inline int dayOfTheYear(int day, int month);
inline yList *modeTime(int d,char mode);
void setTime(AlertList *root, xmlNode *father);
dailyAlertList *lastTimestamp(iDay *today, int year, long int ts);
dailyAlertList *scanYear(yList *curyear, long int ts);
int parse_time(processingTree *this,char *where,int index,int *i);
void del_time_index(AlertList *to_delete);
void indexTime(AlertList *root,xmlNode *father, char mode);
xmlNodeList *time_filters(processingTree *this,stringList *sel,VortexConnection *cn,VortexChannel *ch);
xmlNodeList *TimeFilter(unsigned char sign_mode,int sign_num,int step_num,const char *timestamp, char mode,stringList *sel,VortexConnection *cn,VortexChannel *ch);
xmlNodeList *notTimeFilter(unsigned char sign_mode,int sign_num,int step_num,const char *tstamp, char mode,stringList *sel,VortexConnection *cn,VortexChannel *ch);
xmlNodeList *betweenTime(unsigned char sign_mode,int sign_num,int step_num,char *time, char mode,stringList *sel,VortexConnection *cn,VortexChannel *ch);
xmlNodeList *notbetweenTime(unsigned char sign_mode,int sign_num,int step_num,char *time, char mode,stringList *sel,VortexConnection *cn,VortexChannel *ch);
#endif

#endif
